<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?
function SQLResultTable($Query)
{
    $link = mysql_connect(localhost, deb46160 , d3e01tGF) or die('Could not connect: ' . mysql_error());      //link met de database
    mysql_select_db(deb46160_PizzaRio) or die('Could not select database');        //selecteer de juiste database
    $Table = "";  //initializeer tabel variable
   
    $Table.= "<table border='1' style=\"border-collapse: collapse;\">"; //Open HTML Table
   
    $Result = mysql_query($Query); //uitvoeren van de query
    if(mysql_error())
    {
        $Table.= "<tr><td>MySQL ERROR: " . mysql_error() . "</td></tr>";
    }
    else
    {
        //header van de tabel met namen van de velden
        $NumFields = mysql_num_fields($Result);
        $Table.= "<tr style=\"background-color: #000066; color: #FFFFFF;\">"; //stijl van de header
        for ($i=0; $i < $NumFields; $i++)
        {    
            $Table.= "<th>" . mysql_field_name($Result, $i) . "</th>";
        }
        $Table.= "</tr>";
   
        //resultaten van de query worden hier in de tabel gezet dmv een loop
        $RowCt = 0; //Row Counter
        while($Row = mysql_fetch_assoc($Result))
        {
            //om en om andere kleur
            if($RowCt++ % 2 == 0) $Style = "background-color: #FFFFFF;"; //stijl 1
            else $Style = "background-color: #F0F0F0;"; // stijl2
           
            $Table.= "<tr style=\"$Style\">";
            //Loop door elk veld
            foreach($Row as $field => $value)
            {
                $Table.= "<td>$value</td>";
            }
            $Table.= "</tr>";
        }
        
    }
    $Table.= "</table>";
   
    return $Table;
}
?>
</body>
</html>